package it.giuseppetrisciuoglio.lyrics.persistence.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name = "TB_ALBUM")
public class Album extends CommonClass {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "NUM_ALBUM")
	Long id;
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "NUM_ARTISTA")
	Artista artista;
	@Column(name = "TXT_ANNO")
	String anno;
	@Column(name = "TXT_TITOLO")
	String titolo;
	@Column(name="TXT_MBID")
	String mbid;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "ALBUM_CANZONI",
			joinColumns=@JoinColumn(name="NUM_ALBUM"),inverseJoinColumns=@JoinColumn(name="NUM_CANZONE"))
	List<Canzone> canzoni = new ArrayList<Canzone>();
	
	@Version
	@Column(name="NUM_VERSION")
	Long version;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Artista getArtista() {
		return artista;
	}

	public void setArtista(Artista artista) {
		this.artista = artista;
	}

	public String getAnno() {
		return anno;
	}

	public void setAnno(String anno) {
		this.anno = anno;
	}

	public String getTitolo() {
		return titolo;
	}

	public void setTitolo(String titolo) {
		this.titolo = titolo;
	}

	public List<Canzone> getCanzoni() {
		return canzoni;
	}

	public void setCanzoni(List<Canzone> canzoni) {
		this.canzoni = canzoni;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public String getMbid() {
		return mbid;
	}

	public void setMbid(String mbid) {
		this.mbid = mbid;
	}
	
	
	
	

}
